<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.9.1"/>
<title>knet: 定时器</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">knet
   &#160;<span id="projectnumber">1.4.3</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.8.9.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'搜索');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>首页</span></a></li>
      <li><a href="modules.html"><span>模块</span></a></li>
      <li><a href="annotated.html"><span>类</span></a></li>
      <li><a href="files.html"><span>文件</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="搜索" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">函数</a>  </div>
  <div class="headertitle">
<div class="title">定时器</div>  </div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
函数</h2></td></tr>
<tr class="memitem:gaef96e7c368db456236a2121e3d75c49c"><td class="memItemLeft" align="right" valign="top"><a class="el" href="struct__ktimer__loop__t.html">ktimer_loop_t</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__timer.html#gaef96e7c368db456236a2121e3d75c49c">ktimer_loop_create</a> (time_t freq, int slot)</td></tr>
<tr class="separator:gaef96e7c368db456236a2121e3d75c49c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad3dafe93f5b45424bd5983ef0c163687"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__timer.html#gad3dafe93f5b45424bd5983ef0c163687">ktimer_loop_destroy</a> (<a class="el" href="struct__ktimer__loop__t.html">ktimer_loop_t</a> *ktimer_loop)</td></tr>
<tr class="separator:gad3dafe93f5b45424bd5983ef0c163687"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaf195cf4006bced494e99242c36ad36c0"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__timer.html#gaf195cf4006bced494e99242c36ad36c0">ktimer_loop_run_once</a> (<a class="el" href="struct__ktimer__loop__t.html">ktimer_loop_t</a> *ktimer_loop)</td></tr>
<tr class="separator:gaf195cf4006bced494e99242c36ad36c0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga5e31b2fc26af005e97b09804c5a98099"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__timer.html#ga5e31b2fc26af005e97b09804c5a98099">ktimer_loop_run</a> (<a class="el" href="struct__ktimer__loop__t.html">ktimer_loop_t</a> *ktimer_loop)</td></tr>
<tr class="separator:ga5e31b2fc26af005e97b09804c5a98099"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga9d51f5fa5d9609d783eb4b0e05101079"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__timer.html#ga9d51f5fa5d9609d783eb4b0e05101079">ktimer_loop_exit</a> (<a class="el" href="struct__ktimer__loop__t.html">ktimer_loop_t</a> *ktimer_loop)</td></tr>
<tr class="separator:ga9d51f5fa5d9609d783eb4b0e05101079"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga37901569361ae2a726a1973d7da2d6e5"><td class="memItemLeft" align="right" valign="top"><a class="el" href="struct__ktimer__t.html">ktimer_t</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__timer.html#ga37901569361ae2a726a1973d7da2d6e5">ktimer_create</a> (<a class="el" href="struct__ktimer__loop__t.html">ktimer_loop_t</a> *ktimer_loop)</td></tr>
<tr class="separator:ga37901569361ae2a726a1973d7da2d6e5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga1465f5ddec41fa81c429d1647dc5e7a9"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__timer.html#ga1465f5ddec41fa81c429d1647dc5e7a9">ktimer_stop</a> (<a class="el" href="struct__ktimer__t.html">ktimer_t</a> *timer)</td></tr>
<tr class="separator:ga1465f5ddec41fa81c429d1647dc5e7a9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad2c8d1024db56a0bef97ea47fb07a920"><td class="memItemLeft" align="right" valign="top"><a class="el" href="struct__ktimer__loop__t.html">ktimer_loop_t</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__timer.html#gad2c8d1024db56a0bef97ea47fb07a920">ktimer_get_loop</a> (<a class="el" href="struct__ktimer__t.html">ktimer_t</a> *timer)</td></tr>
<tr class="separator:gad2c8d1024db56a0bef97ea47fb07a920"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga8c5900fb62a63dc71cc9f38ac6427ad1"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__timer.html#ga8c5900fb62a63dc71cc9f38ac6427ad1">ktimer_start</a> (<a class="el" href="struct__ktimer__t.html">ktimer_t</a> *timer, ktimer_cb_t cb, void *data, time_t ms)</td></tr>
<tr class="separator:ga8c5900fb62a63dc71cc9f38ac6427ad1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga9c37409260a72e3218ae4fcaf44d79bc"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__timer.html#ga9c37409260a72e3218ae4fcaf44d79bc">ktimer_start_once</a> (<a class="el" href="struct__ktimer__t.html">ktimer_t</a> *timer, ktimer_cb_t cb, void *data, time_t ms)</td></tr>
<tr class="separator:ga9c37409260a72e3218ae4fcaf44d79bc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga285936846760d9f325e588d2e2105fe5"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__timer.html#ga285936846760d9f325e588d2e2105fe5">ktimer_start_times</a> (<a class="el" href="struct__ktimer__t.html">ktimer_t</a> *timer, ktimer_cb_t cb, void *data, time_t ms, int times)</td></tr>
<tr class="separator:ga285936846760d9f325e588d2e2105fe5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga9387b99ff760183fe8b61c8c46d6efc8"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__timer.html#ga9387b99ff760183fe8b61c8c46d6efc8">ktimer_check_dead</a> (<a class="el" href="struct__ktimer__t.html">ktimer_t</a> *timer)</td></tr>
<tr class="separator:ga9387b99ff760183fe8b61c8c46d6efc8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga71282c2dc8bac0935617b1271f4066e6"><td class="memItemLeft" align="right" valign="top">time_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__timer.html#ga71282c2dc8bac0935617b1271f4066e6">ktimer_loop_get_tick_intval</a> (<a class="el" href="struct__ktimer__loop__t.html">ktimer_loop_t</a> *ktimer_loop)</td></tr>
<tr class="separator:ga71282c2dc8bac0935617b1271f4066e6"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">详细描述</h2>
<pre>
定时器</pre><pre>定时器并没有放在loop_t内处理，而是提供了独立的ktimer_loop_t来处理定时器.
有3种定时器类型:</pre><pre>1. 周期性定时器     ktimer_start启动
2. 运行一次的定时器  ktimer_start_once启动
3. 运行多次的定时器  ktimer_start_times启动</pre><pre>定时器的处理方式通过回调函数，与传统的定时器激发方式相同，内部实现采纳了
时间轮的概念(不完全是传统意义的时间轮)，定时器的加入和删除的时间复杂度都是O(1)，
如果调用ktimer_loop_run_once来自己手动触发，定时器的激发不能保证完全准确，
这取决于你的调用周期是否&lt;=时间轮的转动频率.</pre><pre>ktimer_loop_run内部使用操作系统提供的毫秒级睡眠函数来模拟间隔，防止CPU空转，
但操作系统提供的睡眠函数通常是不准确的，如果睡眠&gt;=调度时间片，通常误差为百分之2以内,
这对于非毫秒级精确度通常是够用的，但是低于10毫秒分辨率的定时器会有非常大的误差，如果需要
精确的定时器，需要调用操作系统高分辨率时间函数来自行处理.</pre><pre></pre> <h2 class="groupheader">函数说明</h2>
<a class="anchor" id="ga9387b99ff760183fe8b61c8c46d6efc8"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int ktimer_check_dead </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct__ktimer__t.html">ktimer_t</a> *&#160;</td>
          <td class="paramname"><em>timer</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>检查定时器是否在回调函数返回即将被销毁 </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">timer</td><td>ktimer_t实例 </td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>返回值</dt><dd>
  <table class="retval">
    <tr><td class="paramname">0</td><td>不是 </td></tr>
    <tr><td class="paramname">非零</td><td>是 </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga37901569361ae2a726a1973d7da2d6e5"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="struct__ktimer__t.html">ktimer_t</a>* ktimer_create </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct__ktimer__loop__t.html">ktimer_loop_t</a> *&#160;</td>
          <td class="paramname"><em>ktimer_loop</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>创建一个定时器 </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">ktimer_loop</td><td>ktimer_loop_t实例 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>ktimer_t实例 </dd></dl>

</div>
</div>
<a class="anchor" id="gad2c8d1024db56a0bef97ea47fb07a920"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="struct__ktimer__loop__t.html">ktimer_loop_t</a>* ktimer_get_loop </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct__ktimer__t.html">ktimer_t</a> *&#160;</td>
          <td class="paramname"><em>timer</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>取得ktimer_loop_t实例 </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">timer</td><td>ktimer_t实例 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>ktimer_loop_t实例 </dd></dl>

</div>
</div>
<a class="anchor" id="gaef96e7c368db456236a2121e3d75c49c"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="struct__ktimer__loop__t.html">ktimer_loop_t</a>* ktimer_loop_create </td>
          <td>(</td>
          <td class="paramtype">time_t&#160;</td>
          <td class="paramname"><em>freq</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>slot</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>创建定时器循环 </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">freq</td><td>最小分辨率（毫秒） </td></tr>
    <tr><td class="paramname">slot</td><td>时间轮槽位数量 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>ktimer_loop_t实例 </dd></dl>

</div>
</div>
<a class="anchor" id="gad3dafe93f5b45424bd5983ef0c163687"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void ktimer_loop_destroy </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct__ktimer__loop__t.html">ktimer_loop_t</a> *&#160;</td>
          <td class="paramname"><em>ktimer_loop</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>销毁定时器循环 </p><dl class="section return"><dt>返回</dt><dd>ktimer_loop_t实例 </dd></dl>

</div>
</div>
<a class="anchor" id="ga9d51f5fa5d9609d783eb4b0e05101079"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void ktimer_loop_exit </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct__ktimer__loop__t.html">ktimer_loop_t</a> *&#160;</td>
          <td class="paramname"><em>ktimer_loop</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>退出ktimer_loop_run() </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">ktimer_loop</td><td>ktimer_loop_t实例 </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga71282c2dc8bac0935617b1271f4066e6"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">time_t ktimer_loop_get_tick_intval </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct__ktimer__loop__t.html">ktimer_loop_t</a> *&#160;</td>
          <td class="paramname"><em>ktimer_loop</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>取得滴答间隔 </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">ktimer_loop</td><td>ktimer_loop_t实例 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>滴答间隔 </dd></dl>

</div>
</div>
<a class="anchor" id="ga5e31b2fc26af005e97b09804c5a98099"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void ktimer_loop_run </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct__ktimer__loop__t.html">ktimer_loop_t</a> *&#160;</td>
          <td class="paramname"><em>ktimer_loop</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>循环检查定时器超时，调用ktimer_loop_exit()退出 </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">ktimer_loop</td><td>ktimer_loop_t实例 </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="gaf195cf4006bced494e99242c36ad36c0"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int ktimer_loop_run_once </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct__ktimer__loop__t.html">ktimer_loop_t</a> *&#160;</td>
          <td class="paramname"><em>ktimer_loop</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>检查定时器超时，如果超时调用定时器回调 </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">ktimer_loop</td><td>ktimer_loop_t实例 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>定时器超时的数量 </dd></dl>

</div>
</div>
<a class="anchor" id="ga8c5900fb62a63dc71cc9f38ac6427ad1"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int ktimer_start </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct__ktimer__t.html">ktimer_t</a> *&#160;</td>
          <td class="paramname"><em>timer</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">ktimer_cb_t&#160;</td>
          <td class="paramname"><em>cb</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">time_t&#160;</td>
          <td class="paramname"><em>ms</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>启动一个无限次数的定时器 </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">timer</td><td>ktimer_t实例 </td></tr>
    <tr><td class="paramname">cb</td><td>超时回调函数 </td></tr>
    <tr><td class="paramname">data</td><td>回调函数参数 </td></tr>
    <tr><td class="paramname">ms</td><td>定时器超时间隔 </td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>返回值</dt><dd>
  <table class="retval">
    <tr><td class="paramname">error_ok</td><td>成功 </td></tr>
    <tr><td class="paramname">其他</td><td>失败 </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga9c37409260a72e3218ae4fcaf44d79bc"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int ktimer_start_once </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct__ktimer__t.html">ktimer_t</a> *&#160;</td>
          <td class="paramname"><em>timer</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">ktimer_cb_t&#160;</td>
          <td class="paramname"><em>cb</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">time_t&#160;</td>
          <td class="paramname"><em>ms</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>启动一个只超时一次的定时器，超时后将自动销毁 </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">timer</td><td>ktimer_t实例 </td></tr>
    <tr><td class="paramname">cb</td><td>超时回调函数 </td></tr>
    <tr><td class="paramname">data</td><td>回调函数参数 </td></tr>
    <tr><td class="paramname">ms</td><td>定时器超时间隔 </td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>返回值</dt><dd>
  <table class="retval">
    <tr><td class="paramname">error_ok</td><td>成功 </td></tr>
    <tr><td class="paramname">其他</td><td>失败 </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga285936846760d9f325e588d2e2105fe5"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int ktimer_start_times </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct__ktimer__t.html">ktimer_t</a> *&#160;</td>
          <td class="paramname"><em>timer</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">ktimer_cb_t&#160;</td>
          <td class="paramname"><em>cb</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">time_t&#160;</td>
          <td class="paramname"><em>ms</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>times</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>启动一个有限次数的定时器，达到times次数后将自动销毁 </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">timer</td><td>ktimer_t实例 </td></tr>
    <tr><td class="paramname">cb</td><td>超时回调函数 </td></tr>
    <tr><td class="paramname">data</td><td>回调函数参数 </td></tr>
    <tr><td class="paramname">ms</td><td>定时器超时间隔 </td></tr>
    <tr><td class="paramname">times</td><td>次数 </td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>返回值</dt><dd>
  <table class="retval">
    <tr><td class="paramname">error_ok</td><td>成功 </td></tr>
    <tr><td class="paramname">其他</td><td>失败 </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga1465f5ddec41fa81c429d1647dc5e7a9"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int ktimer_stop </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="struct__ktimer__t.html">ktimer_t</a> *&#160;</td>
          <td class="paramname"><em>timer</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>停止并销毁定时器 </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">timer</td><td>ktimer_t实例 </td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>返回值</dt><dd>
  <table class="retval">
    <tr><td class="paramname">error_ok</td><td>成功 </td></tr>
    <tr><td class="paramname">其他</td><td>失败 </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
生成于 2015年 七月 9日 星期四 14:59:53 , 为 knet使用  &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.9.1
</small></address>
</body>
</html>
